package com.geekgo.flowcontroller.common;

import com.geekgo.flowcontroller.annotation.DPSRate;
import com.geekgo.flowcontroller.annotation.RateLimit;
import com.geekgo.flowcontroller.core.RateLimitStrategy;
import com.geekgo.flowcontroller.core.converter.IRateConverter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author geekgo
 * @version 2016/8/4 17:58
 */
public class DPSRateBean extends RateLimitBean {

    private IRateConverter converter;

    public DPSRateBean(DPSRate dpsRate, IRateConverter converter,RateLimitBean father) {
        this.setKey(StringUtils.isEmpty(dpsRate.key())?father.getKey():dpsRate.key());
        this.setRate(dpsRate.rate()>0?dpsRate.rate():father.getRate());
        this.setStrategy(dpsRate.strategy());
        setConverter(converter);
    }

    public IRateConverter getConverter() {
        return converter;
    }

    public void setConverter(IRateConverter converter) {
        this.converter = converter;
    }
}
